package com.code.softeem.zuoye.demo3;

import java.util.Scanner;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/3/20 18:04
 * @description
 */
public class Bank {
    /*
    银行名称 bankName
		所在国家名称： countryName（注所有银行都是在中国）
		所有银行已发出的卡数 totalCardNumber
		本银行累计存款金额 totalDeposit
		本银行累计取款金额 totalWithdraw
		所有银行累计存款金额 allTotalDeposit
		所有银行累计取款金额 allTotalWithDraw

     */
    private String bankName;
    private final String countryName = "china";
    private static int totalCardNumber = 0;
    private double totalDeposit = 0;
    private double totalWithdraw = 0;
    private static double allTotalDeposit = 0;
    private static double allTotalWithDraw = 0;

    public Bank() {
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getCountryName() {
        return countryName;
    }

    public int getTotalCardNumber() {
        return totalCardNumber;
    }

    public void setTotalCardNumber(int totalCardNumber) {
        this.totalCardNumber = totalCardNumber;
    }

    public double getTotalDeposit() {
        return totalDeposit;
    }

    public void setTotalDeposit(double totalDeposit) {
        this.totalDeposit = totalDeposit;
    }

    public double getTotalWithdraw() {
        return totalWithdraw;
    }

    public void setTotalWithdraw(double totalWithdraw) {
        this.totalWithdraw = totalWithdraw;
    }

    public static double getAllTotalDeposit(Bank bank1,Bank bank2) {
        allTotalDeposit=bank1.getTotalDeposit()+bank2.getTotalDeposit();
        return allTotalDeposit;
    }

    public void setAllTotalDeposit(double allTotalDeposit) {
        this.allTotalDeposit = allTotalDeposit;
    }

    public static double getAllTotalWithDraw(Bank bank1,Bank bank2) {
        allTotalWithDraw = bank1.getTotalWithdraw()+bank2.getTotalWithdraw();
        return allTotalWithDraw;
    }

    public void setAllTotalWithDraw(double allTotalWithDraw) {
        this.allTotalWithDraw = allTotalWithDraw;
    }

    public BankCard createCard(){//发卡
        BankCard bankCard = new BankCard();
        bankCard.setNextNo(bankCard.getNextNo()+1);
        bankCard.setTotalBalance(bankCard.getTotalBalance());
        Scanner input = new Scanner(System.in);
        System.out.print("请输入要创建的银行卡号:");
        String cardNo = input.next();
        bankCard.setCardNo(cardNo);
        System.out.print("请输入姓名:");
        String name = input.next();
        bankCard.setName(name);
        System.out.print("请输入客户身份证号:");
        String personId = input.next();
        bankCard.setPersonId(personId);

        bankCard.setBalance(0);//新卡余额为0

        totalCardNumber++;

        return bankCard;
    }
    public void deposit(BankCard bankCard,Bank bank){//存款
        System.out.print("卡号为"+bankCard.getCardNo()+"请输入存款金额");
        Scanner input = new Scanner(System.in);
        double balance = input.nextDouble();
        bankCard.setBalance(bankCard.getBalance()+balance);

        bankCard.setTotalBalance(bankCard.getTotalBalance()+balance);
        bank.setTotalDeposit(bank.getTotalDeposit()+balance);
//        bank.setAllTotalDeposit(bank.getAllTotalDeposit()+balance);

        System.out.println("卡号"+bankCard.getCardNo()+"当前余额为： " + bankCard.getBalance());
//        System.out.println("该银行累计存款"+bank.getTotalDeposit());
    }
    public void withdraw(BankCard bankCard,Bank bank){//取款
        System.out.print("卡号为"+bankCard.getCardNo()+"请输入取款金额");
        Scanner input = new Scanner(System.in);
        double balance = input.nextDouble();
        bankCard.setBalance(bankCard.getBalance()-balance);

        bankCard.setTotalBalance(bankCard.getTotalBalance()-balance);
        bank.setTotalWithdraw(bank.getTotalWithdraw()+balance);
//        bank.setAllTotalWithDraw(bank.getAllTotalWithDraw()+balance);

        System.out.println("卡号"+bankCard.getCardNo()+"当前余额为： " + bankCard.getBalance());
//        System.out.println("该银行累计取款"+bank.getTotalWithdraw());

    }
}
